package org.xxpay.pay.channel.hgpay;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * pangxiaoyu
 * 2020年4月14日12:09:02
 */
@Component
public class HgpayConfig {

    public static final String CHANNEL_NAME = "hgpay";
    protected final static String CHANNEL_NAME_ALIPAY_QR = CHANNEL_NAME + "_alipay_qr";   // 支付宝扫码
    protected final static String CHANNEL_NAME_ALIPAY_H5 = CHANNEL_NAME + "_alipay_h5";   // 支付宝H5

    public static final String CHANNEL_PAY_TYPE = "alipay";    // 支付方式

    public static final String RETURN_VALUE_SUCCESS = "success";    //回调返回状态
    public static final String RETURN_VALUE_ERROR = "error";

    // 应用账号
    private String appId;
    // 秘钥
    private String key;
    // 请求地址
    private String reqUrl;

    public HgpayConfig(){}

    public HgpayConfig(String payParam) {
        Assert.notNull(payParam, "init " + CHANNEL_NAME +" config error");
        JSONObject object = JSONObject.parseObject(payParam);
        this.appId = object.getString("appId");
        this.key = object.getString("key");
        this.reqUrl = object.getString("reqUrl");
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getReqUrl() {
        return reqUrl;
    }

    public void setReqUrl(String reqUrl) {
        this.reqUrl = reqUrl;
    }
}
